package com.neusoft.dibuy.kafka.producer.interceptor;

import org.apache.kafka.clients.producer.ProducerInterceptor;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.apache.kafka.common.protocol.types.Field;

import java.util.Map;

public class ValueInterceptor implements ProducerInterceptor<String, String> {
    /**
     * 每次发送
     *
     * @param record
     * @return
     */

    @Override
    public ProducerRecord<String, String> onSend(ProducerRecord<String, String> record) {
        System.out.println("ValueInterceptor.onSend");

        /**
         * TODO : 拦截器不可以修改消息
         *
         */


        return null;
    }

    /**
     * 响应返回
     *
     * @param metadata
     * @param exception
     */
    @Override
    public void onAcknowledgement(RecordMetadata metadata, Exception exception) {
        System.out.println("ValueInterceptor.onAcknowledgement");

    }

    /**
     * 生产者关闭
     */

    @Override
    public void close() {
        System.out.println("ValueInterceptor.close");

    }

    /**
     * 配置调整
     *
     * @param configs
     */

    @Override
    public void configure(Map<String, ?> configs) {

    }
}
